package br.com.foxinline.servico;

import br.com.foxinline.generico.ServicoGenerico;
import br.com.foxinline.modelo.HistoricoRevisaoAlinhamento;
import br.com.foxinline.modelo.Imovel;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author elyjunior
 */
@Stateless
public class HistoricoRevisaoAlinhamentoServico extends ServicoGenerico<HistoricoRevisaoAlinhamento> {

    public HistoricoRevisaoAlinhamentoServico() {
        super(HistoricoRevisaoAlinhamento.class);
    }

    public List<HistoricoRevisaoAlinhamento> lstHistoricoRevisaoAlinhamento(Imovel imovel) {
        String sql = "SELECT h FROM HistoricoRevisaoAlinhamento h JOIN h.revisaoAlinhamento r JOIN r.imovel i WHERE i.id = :id";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("id", imovel.getId());
        return (List<HistoricoRevisaoAlinhamento>) query.getResultList();
    }
}
